<template>
  <div class="app">
    <keep-alive>
      <router-view v-if="keepAlive"/>
    </keep-alive>
    <router-view v-if="!keepAlive"/>
  </div>
</template>

<script>
export default {
  name: 'App',
  data() {
    return {
      keepAlive: false
    }
  },
  created() {
    // 清空本地缓存
    // window.localStorage.clear()
    // console.log('清空本地存储完成')
  },
  watch: {
    $route(to) {
      console.log('route to:', to)
      const { meta: { keepAlive } } = to
      this.keepAlive = keepAlive
    }
  },
  errorCaptured(err, vm, info) {
    console.log('errorCaptured err', err)
    console.log('errorCaptured vm', vm)
    console.log('errorCaptured info', info)
  }
}
</script>
